import os

def count_lines(project_path, code_extensions):
    total_lines = 0
    for root, _, files in os.walk(project_path):
        for file in files:
            if any(file.endswith(ext) for ext in code_extensions):
                file_path = os.path.join(root, file)
                try:
                    with open(file_path, 'r', encoding='utf-8') as f:
                        total_lines += len(f.readlines())
                except UnicodeDecodeError:
                    print(f"Warning: Unable to decode file {file_path}, skipping.")
                except Exception as e:
                    print(f"Error processing file {file_path}: {e}")
    return total_lines

if __name__ == "__main__":
    project_path = r"E:\PythonProjiects\CDS_Download"
    code_extensions = ['.py', '.java', '.cpp']
    print(f'Total lines of code: {count_lines(project_path, code_extensions)}')